﻿using System;

namespace FX.CC.Andon.Utility.Common
{
    /// <summary>
    /// 数据库备份或还原
    /// </summary>
    public class DbBackupOrRestore
    {
        //public bool DbBackup()
        //{
        //    string conn, server, uid, pwd, database;
        //    conn = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToString();
        //    var arrlist = conn.Split(';');
        //    var arrSource = arrlist[0].Split('=');
        //    server = arrSource[1];
        //    var arrUid = arrlist[3].Split('=');
        //    uid = arrUid[1];
        //    var arrPwd = arrlist[4].Split('=');
        //    pwd = arrPwd[1];
        //    var arrDataBase = arrlist[1].Split('=');
        //    database = arrDataBase[1];
        //    //string path = this.TextBox2.Text.Trim();
        //    SQLDMO.Backup oBackup = new SQLDMO.BackupClass();
        //    SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass();
        //    try
        //    {
        //        oSQLServer.LoginSecure = false;
        //        oSQLServer.Connect(server, uid, pwd);
        //        oBackup.Action = SQLDMO.SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database;
        //        oBackup.Database = database;
        //        oBackup.Files = "";
        //        oBackup.BackupSetName = database;
        //        oBackup.BackupSetDescription = "数据库备份";
        //        oBackup.Initialize = true;
        //        oBackup.SQLBackup(oSQLServer);

        //        return true;
        //    }
        //    catch (Exception ex)
        //    {
        //        EventsLog.WriteLog("ErrorInfo" + ex.Message);
        //        return false;
        //    }
        //    finally
        //    {
        //        oSQLServer.DisConnect();
        //    }
        //}
    }
}
